<template>
  <section class="navbar">

    <div class="system-name">{{ systemName }}</div>

    <div class="user-info-item">
      <!-- <span>当前用户：{{  currentUser }}</span> -->
      <!-- <img class="quitBtn" src='../../assets/quit.png' />
      <img @click="changePassword"/> -->
      <!-- trigger="click" -->
        <el-dropdown @command="handleCommand">
          <span class="el-dropdown-link">
            当前用户：{{  currentUser }}<i class="el-icon-arrow-down el-icon--right"></i>
          </span>
          <el-dropdown-menu slot="dropdown">
            <el-dropdown-item command='goback' icon="el-icon-edit-outline">返回系统</el-dropdown-item>
            <!-- <el-dropdown-item command='logout' icon="el-icon-switch-button">退出</el-dropdown-item> -->
          </el-dropdown-menu>
        </el-dropdown>
    </div>
  </section>
</template>

<script>
import cookies from '@/utils/cookies'
export default {
  data () {
    return {
      systemName: '临湘市乡村地名大数据系统-用户管理',
      currentDateTime: '',
      currentUser: ''
    }
  },
  mounted () {
    this.currentUser = cookies.getCookies('current_user')
  },
  methods: {

    handleCommand (command) {
      if (command === 'logout') {
        this.logout()
      } else if (command === 'goback') {
        this.$router.push('/home')
      }
    },
    // 注销，登出
    async logout () {
      await this.$store.dispatch('user/logout')
      cookies.removeCookies('current_user')
      this.$router.push(`/login?redirect=${this.$route.fullPath}`)
    }
  }
}
</script>
<!-- lang="scss"  -->
<style lang="less" scoped>
.navbar {
  // height: 120px;
  overflow: hidden;
  // background: rgb(31, 82, 130, 1.0);
  // box-shadow: 0 1px 4px rgba(0,21,41,.08);
  background: linear-gradient(90deg, #2665b2 0%, #293d9a 100%);
  box-shadow: 0px 3px 6px rgba(0, 0, 0, 0.16);

  .system-name {
    height: 100%;
    line-height: 100%;
    padding-left:10px;
  }

  .system-name{
    float: left;
    font-size: 30px;
    color: white;
    line-height: 80px;
  }

  .user-info-item{
    height: 20px;
    position: absolute;
    right: 10px;
    top:30px;
    .el-dropdown-link {
      cursor: pointer;
      color:white;
    }
  }

  .right-menu {
    float: right;
    height: 100%;
    line-height: 50px;

    &:focus {
      outline: none;
    }

    .right-menu-item {
      display: inline-block;
      padding: 0 8px;
      height: 100%;
      font-size: 18px;
      color: #5a5e66;
      vertical-align: text-bottom;

      &.hover-effect {
        cursor: pointer;
        transition: background .3s;

        &:hover {
          background: rgba(0, 0, 0, .025)
        }
      }
    }

    .avatar-container {
      margin-right: 30px;

      .avatar-wrapper {
        margin-top: 5px;
        position: relative;

        .user-avatar {
          cursor: pointer;
          width: 40px;
          height: 40px;
          border-radius: 10px;
        }

        .el-icon-caret-bottom {
          cursor: pointer;
          position: absolute;
          right: -20px;
          top: 25px;
          font-size: 12px;
        }
      }
    }
  }
}
</style>
